<template>
    <div class="changeBox2">
        <div class="closeBox">
                <div @click="$emit('close')"></div>
        </div>
        <!-- 查询 -->
        <div class="UserBox1">
            <form>
                <div class="oneInput">台：<input type="number" min="0" v-model="GTableId"></div>
                <div class="oneInput">靴：<input type="number" min="0" v-model="Xue"></div>
                <div class="oneInput">局：<input type="number" min="0" v-model="Ju"></div>
                <div class="twoInput">
                    游戏类型：<select v-model="GameType"><option value="全部" >全部</option><option value="1" >百家乐</option><option value="2" >龙虎</option><option value="5" >牛牛</option></select>
                </div>
                <div class="timeInput">
                    下注时间：
                        <input @click="openTime=!openTime;openToTime=false" v-model="StartDate" type="text">
                    至：
                        <input @click="openToTime=!openToTime;openTime=false"  v-model="EndDate" type="text">
                </div>
                <!-- 开始日期控件 -->
                <div id='schedule-box' v-show="openTime"  class="boxshaw"></div>
                <!-- 结束日期控件 -->
                <div id='schedule2' v-show="openToTime"  class="boxshaw"></div>
                <!-- 提交 -->
                <div class="postInput">
                    <input type="button" value="" @click="getNewGameLog()">
                </div>
            </form>
        </div>
        <!-- 列表数据 -->
        <div class="UserBox2">
            <table border="0" cellpadding="0" cellspacing="0" width="100%">
                <tr style="height:38px;font-size:13px;background:#282828">
                    <td>游戏类型</td>
                    <td>注单号</td>
                    <td>日期时间</td>
                    <td>台/靴/局</td>
                    <td>投注点</td>
                    <td>牌面</td>
                    <td>开局结果</td>
                    <td style="text-align:center;">输赢</td>
                </tr>
                <tr v-for="(conters,idx) in table" v-bind:key=idx>
                    <td class="game1">{{conters.GameType}}</td>
                    <td class="game2">{{conters.AutoId}}</td>
                    <td class="game3">{{conters.AddDate}}</td>
                    <td class="game4">{{conters.RXJ}}</td>
                    <td class="game5 NumPush">{{conters.BetMoney}}</td>
                    <td class="game6">{{conters.PaiMian}}</td>
                    <td class="game7 NumPush3">{{conters.OpenResult}}</td>
                    <td class="game8" style="text-align:center;" :class="{'NumPush':conters.WinMoney>0,'NumPush2':conters.WinMoney<0}">{{conters.WinMoney}}</td>
                </tr>
            </table>
        </div>
        <div class="UserBox3">
            <div><p>总赢利：￥{{allWin}}</p></div>
            <div class="a1"><p>总赔彩： ￥<span style="color:#fca200">{{loserMoney}}</span></p></div>
            <div class="a1"><p>总投注：￥<span style="color:#e40101">{{biuMoney}}</span></p></div>
        </div>
        <!-- 翻页 -->
        <div class="UserBox4">
            <div class="page">
                <div class="pd pageGo" style="float: right" @click="getNewGameLog(pageThis+1)" v-show="Count>1"><span></span>下一页</div>

                <div style="float: right">
                    <div  class="pageGo" v-for="gamePage in Count" v-show="gamePage>pageThis-3&&gamePage<pageThis+3" :class="{'pageThis':pageThis==gamePage}" :key="gamePage" @click="getNewGameLog(gamePage)">{{gamePage}}</div>
                </div>
                
                <div class="pn pageGo" style="float: right" @click="getNewGameLog(pageThis-1)" v-show="Count>1" ><span></span>上一页</div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name:"getGameLog",
    data(){
		return {
			starTimeJS:null,
			openTime:false,
			StartDate:"",
			toTimeJS:null,
			openToTime:false,
			EndDate:"",
			GTableId:0,
			Xue:0,
			Ju:0,
			GameType:'全部'
		}
	},
	computed:{
		table(){
			return this.$store.getters["log/gameLog"];
		},
		Count(){
			var a=this.$store.getters['log/gameLogAll'];
			a=Math.ceil(Math.ceil(a)/10);
			return a;	
		},
		pageThis(){
			return this.$store.getters['log/gameLogThis'];
		},
		biuMoney(){
			return this.$store.getters['log/biuMoney'];
		},
		loserMoney(){
			return this.$store.getters['log/loserMoney'];
		},
		allWin(){
			return this.$store.getters['log/allWin'];
		}
	},
	methods:{
		getNewGameLog(x){
			if(this.StartDate==""&&!x){
				this.$store.commit("changeTips",{data:"请选择开始日期"});
				return false;
			}
			if(this.EndDate==""&&!x){
				this.$store.commit("changeTips",{data:"请选择结束日期"});
				return false;
			}
			let StartDate =this.StartDate;
			let EndDate=this.EndDate;
			let GTableId=this.GTableId;
			let Xue=this.Xue;
			let Ju=this.Ju;
			let GameType=this.GameType;
			let PageSize=12;
			let CurrentPage=x?x:1;
			let a={StartDate,EndDate,GTableId,Xue,Ju,GameType,PageSize,CurrentPage};
			this.$store.dispatch("log/getGameLog",a);
		}
	},
	mounted(){
		let a=new Date();
		this.StartDate=""+a.getFullYear()+"-"+(a.getMonth()+1)+"-"+a.getDate();
		this.EndDate=""+a.getFullYear()+"-"+(a.getMonth()+1)+"-"+a.getDate();
		this.starTimeJS= new Schedule({
			el: '#schedule-box',
			clickCb:function (y,m,d) {
					this.StartDate=y+"-"+m+"-"+d;
					this.openTime=false;
				}.bind(this)
			})
		this.starTimeJS= new Schedule({
			el: '#schedule2',
			clickCb:function (y,m,d) {
					this.EndDate=y+"-"+m+"-"+d;
					this.openToTime=false;
				}.bind(this)
			})
	}
}
</script>
